package com.itheima.test;

import java.util.Arrays;

public class BubbleSort {

    public static void main(String[] args) {
        sort(new Integer[]{43, 65, 12, 5, 12, 9, 122, 3434, 19, 65, 98});
    }

    public static void sort(Integer[] arrs) {
        System.out.println("排序前" + Arrays.toString(arrs));
        int temp = 0;
        for (int i = 0; i < arrs.length-1; i++) {
            for (int j = 0; j < arrs.length - i -1; j++) {
                if (arrs[j] > arrs[j + 1]) {
                    temp = arrs[j];
                    arrs[j] = arrs[j + 1];
                    arrs[j + 1] = temp;
                }
            }
        }
        System.out.println("排序后" + Arrays.toString(arrs));
    }
}
